package com.hello

import akka.actor.Actor
import akka.actor.ActorSystem
import akka.actor.Props
import akka.actor.ActorRef
import java.util.Date
class HelloActor extends Actor{
  def receive = {
    case "hello" => {
      println("self::"+this.self+","+"sender::"+sender()+",msg::hello")
    }
    case "create" =>{
      this.context.actorOf(Props[HelloActor],"Hello-"+new Date().getTime+"");
    }
    case _ => println("huh?");
  }
}
class HelloAkka {
  
}
object P {
  def P (m:Any) = println(m);
}

object Main  {
  def main(args:Array[String]){
  val system = ActorSystem("HelloSystem");
  val helloActor:ActorRef = system.actorOf(Props[HelloActor],name="helloactor")
  helloActor.tell("create", null)
  Thread sleep 10
  helloActor.tell("create", null)
  Thread sleep 10
  helloActor.tell("create", null)
  Thread sleep 10
  helloActor.tell("create", null)
  Thread sleep 10
  system.actorOf(Props[HelloActor],name="helloactor2")
  system.actorOf(Props[HelloActor],name="helloactor3")
  system.actorOf(Props[HelloActor],name="hi1")
  system.actorOf(Props[HelloActor],name="hi2")
  system.actorOf(Props[HelloActor],name="hi3")
  P P helloActor
  P P system.actorSelection("/user/helloactor/*") ! "hello";
  Thread sleep 1000
  system shutdown
  }
}